#include <iostream>
#include <algorithm>
#include <random>
#include <ctime>
#include "AvlTree.h"

template<typename Comparable>
void Search( const AvlTree<Comparable> & bst, int mindata, int maxdata )
{
  if( !bst.isEmpty() )
    {
      AvlTree<Comparable> rhs=bst;
      if( rhs.Comparesmall( mindata ) )
	Search( rhs.TL(), mindata, maxdata );
      rhs=bst;
      if( rhs.Comparesmall( mindata ) && rhs.Comparebig( maxdata ) )
	rhs.printroot();
      rhs=bst;
      if( rhs.Comparebig( maxdata ) )
	Search( rhs.TR(), mindata, maxdata );
    }
}

int main()
{
  AvlTree<int> jdg;
  int i = 1;
  while(i <= 100000)
    {jdg.insert(i);i++;}
  clock_t start, finish;
  double duration;
  start = clock();
  Search( jdg, 1, 500 );
  finish = clock();
  std::cout << std::endl;
  duration = (double)(finish - start) / CLOCKS_PER_SEC;
  std::cout << duration << " s" << std::endl;
  return 0;
}
